package com.aixin.csopuser.domain;

import com.aixin.csopequity.domain.ServiceLevelDef;
import com.aixin.csopsupplier.domain.ServiceDef;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;

import javax.persistence.*;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.time.Instant;
import java.util.List;
import java.util.Objects;
import java.util.Set;

//@ApiModel(description = "用户权益\n@author ZhangTao")
@Entity
@Table(name = "customerequity")
@Data
@ToString
@NoArgsConstructor
public class CustomerEquity implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @Column(name = "id", length = 32)
    private String id;

    @Column(name = "customerID", length = 32)
    private String customerID;

    @Column(name = "policyNumber", length = 32)
    private String policyNumber;

    @Column(name = "custLevelID", length = 32)
    private String custLevelID;

    @Column(name = "custLevelName", length = 32)
    private String custLevelName;

    @Column(name = "equityID", length = 45)
    private String equityID;

    @Column(name = "equityName", length = 45)
    private String equityName;

    @Column(name = "equityType")
    private Integer equityType;

    @Column(name = "effStrTime")
    private Instant effStrTime;

    @Column(name = "usedTIme")
    private Instant usedTIme;

    @Column(name = "usedNum")
    private Integer usedNumber;

    @ManyToOne(fetch = FetchType.LAZY)
    @JsonIgnoreProperties(value = "customerEquities", allowSetters = true)
    @JoinColumn(name = "customerID",insertable=false, updatable=false)
    private CustomerDomain customer;

    @Transient
    @JsonSerialize
    private List<ServiceDef> services;

    @Transient
    @JsonSerialize
    private PolicyDomain policy;

    @Transient
    @JsonSerialize
    private List<ServiceConsumeHistory> consumeHistories;

    @Override
    public int hashCode() {
        return Objects.hashCode(id);
    }

    public CustomerEquity(String custLevelID) {
        // 获取客户权益ID专用构造方法
        this.custLevelID = custLevelID;
    }
}
